#include "Direction.h"

Direction::Direction(DirectionType newDirection): direction(newDirection)
{
}

Direction::Direction(const Direction& rhs): direction(rhs.direction)
{
}

Direction::~Direction()
{
}


void Direction::SetDirection(const Direction& newDirection)
{
	*this = newDirection;
}

const Direction& Direction::operator=(const Direction& rhs)
{
	direction = rhs.direction;

	return *this;
}

bool Direction::IsNorth() const
{
	return direction == NORTH;
}

bool Direction::IsSouth() const
{
	return direction == SOUTH;
}

bool Direction::IsEast() const
{
	return direction == EAST;
}

bool Direction::IsWest() const
{
	return direction == WEST;
}

void Direction::SetNorth()
{
	direction = NORTH;
}

void Direction::SetSouth()
{
	direction = SOUTH;
}

void Direction::SetEast()
{
	direction = EAST;
}

void Direction::SetWest()
{
	direction = WEST;
}

Direction::DirectionType Direction::Type() const
{
	return direction;
}

void Direction::SetType(DirectionType type)
{
	direction = type;
}

Direction Direction::Opposed() const
{
	switch(direction)
	{
		case NORTH:
			return Direction::SOUTH;
		case WEST:
			return Direction::EAST;
		case SOUTH:
			return Direction::NORTH;
		case EAST:
		default:
			return Direction::WEST;
	}
}

bool Direction::operator==(const Direction& rhs) const
{
	return direction == rhs.direction;
}

bool Direction::operator!=(const Direction& rhs) const
{
	return direction != rhs.direction;
}


std::string Direction::ToString() const
{
	switch(direction)
	{
		case NORTH:
			return "north";
		case WEST:
			return "west";
		case SOUTH:
			return "south";
		case EAST:
			return "east";

		default:
			return "";
	}
}
